﻿using Intorise.API;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Windows.Forms;
using System.Threading;

namespace TestProject1
{


    /// <summary>
    ///这是 HelperTest 的测试类，旨在
    ///包含所有 HelperTest 单元测试
    ///</summary>
    [TestClass()]
    public class HelperTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///获取或设置测试上下文，上下文提供
        ///有关当前测试运行及其功能的信息。
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region 附加测试特性
        // 
        //编写测试时，还可使用以下特性:
        //
        //使用 ClassInitialize 在运行类中的第一个测试前先运行代码
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //使用 ClassCleanup 在运行完类中的所有测试后再运行代码
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //使用 TestInitialize 在运行每个测试前先运行代码
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //使用 TestCleanup 在运行完每个测试后运行代码
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///SendControlKeyEx 的测试
        ///</summary>
        [TestMethod()]
        public void SendControlKeyExTest()
        {
            IntPtr hWnd = (IntPtr)0x000103E2;
            Helper.SendControlKeyEx(hWnd, Keys.F);
        }

        /// <summary>
        ///MouseMove 的测试
        ///</summary>
        [TestMethod()]
        public void MouseMoveTest()
        {
            int x = 80; // TODO: 初始化为适当的值
            int y = 50; // TODO: 初始化为适当的值
            Helper.Width = 1280;
            Helper.Height = 1024;
            Helper.MouseMove(x, y);
            Helper.MouseRightClick(x, y);
            Assert.Inconclusive("无法验证不返回值的方法。");
        }

        /// <summary>
        ///MouseMove 的测试
        ///</summary>
        [TestMethod()]
        public void KeyTest()
        {
            //Thread.Sleep(3000);
            //Helper.KeyDown(Keys.ControlKey);
            //Helper.KeyDown(Keys.F);
            //Thread.Sleep(100);
            //Helper.KeyUp(Keys.F);
            //Helper.KeyUp(Keys.ControlKey);

            //Thread.Sleep(3000);
            //Helper.KeyDown((IntPtr)1052728, Keys.ControlKey);
            //Helper.KeyDown((IntPtr)1052728, Keys.A);
            //Thread.Sleep(100);
            //Helper.KeyUp((IntPtr)1052728, Keys.A);
            //Helper.KeyUp((IntPtr)1052728, Keys.ControlKey);


            //Thread.Sleep(3000);
            ////Helper.KeyDown(Keys.ControlKey);
            //Helper.KeyDown((IntPtr)3874710, Keys.A);
            //Thread.Sleep(100);
            //Helper.KeyDown((IntPtr)3874710, Keys.A);
            //Helper.KeyUp((IntPtr)3874710, Keys.A);
            //Helper.KeyUp(Keys.ControlKey);

            //Thread.Sleep(3000);
            //Helper.KeyRepeat((IntPtr)3874710,Keys.Enter, 1);
            //Helper.KeyRepeat((IntPtr)3874710, Keys.W, 5);

            //Thread.Sleep(3000);
            //Helper.MouseWheel(-2, 432, 219);
            //Thread.Sleep(1000);
            //Helper.MouseWheel(1, 432, 219);

            //Helper.MouseLeftClick((IntPtr)730332, 432, 219);
            //Thread.Sleep(1000);
            //Helper.MouseLeftClick((IntPtr)730332, 853, 548);
            ////Thread.Sleep(1000);
            ////Helper.MouseRightClick((IntPtr)730332, 700, 450);
            //Thread.Sleep(1000);
            //Helper.MouseLeftClick((IntPtr)730332, 853, 518);
            //Thread.Sleep(1000);
            //Helper.MouseWheel((IntPtr)730332, -1, 853, 518);
            //Thread.Sleep(1000);
            //Helper.MouseWheel((IntPtr)730332, -2, 853, 518);

            //：x : 284 , y : 226 , width : 390 , height : 249
            //Thread.Sleep(3000);
            //Helper.MouseLeftDown((IntPtr)2037326, 284, 226);
            //Thread.Sleep(100);
            //Helper.MouseMove((IntPtr)2037326, 284 + 390, 226 + 249);
            //Thread.Sleep(100);
            //Helper.MouseLeftUp((IntPtr)2037326, 284 + 390, 226 + 249);

            //Helper.Width = 1280;
            //Helper.Height = 1024;
            //Thread.Sleep(4000);
            ////Helper.MouseMove(0, 0);
            ////Thread.Sleep(100);
            ////Helper.MouseLeftDown(0, 0);
            ////Thread.Sleep(100);
            ////Helper.MouseMove(1024, 768);
            ////Thread.Sleep(100);
            ////Helper.MouseLeftUp(1024, 768);
            //Helper.MouseMove(20, 20);
            //Thread.Sleep(100);
            //Helper.MouseLeftDoubleClick(20, 20);
            //Thread.Sleep(100);
            //Helper.MouseMove(0, 0);
            //Thread.Sleep(500);
            //Helper.MouseLeftDown(0, 0);
            //Thread.Sleep(1000);
            //Helper.MouseMove(400, 800);
            //Thread.Sleep(1000);
            //Helper.MouseLeftUp(400, 800);

            //Thread.Sleep(4000);
            ////Helper.KeyRepeatBg(Keys.A);
            ////Thread.Sleep(1000);
            ////Helper.KeyStopRepeat(Keys.A);
            ////Thread.Sleep(1000);

            //Helper.KeyRepeatBg((IntPtr)0x000308BA, Keys.B);
            //Helper.KeyRepeatBg((IntPtr)0x000308BA, Keys.A);
            //Thread.Sleep(1500);
            //Helper.KeyStopRepeat(Keys.A);
            //Helper.KeyStopRepeat(Keys.B);
            IntPtr hWnd = (IntPtr)0x000308BA;
            Thread.Sleep(3000);
            //Helper.KeyPress("Hello,world!");
            //Helper.KeyPress(Keys.Enter);
            //Helper.KeyPress(hWnd, Keys.Enter);
            //Helper.KeyPressBg(hWnd, "你好");
            Helper.KeyPress("123456");
        }

        /// <summary>
        ///ClearMemory 的测试
        ///</summary>
        [TestMethod()]
        public void ClearMemoryTest()
        {
            Helper.ClearMemory();
            //Assert.Inconclusive("无法验证不返回值的方法。");
        }
    }
}
